package com.stu.covid.business.utils;

import com.alibaba.excel.annotation.ExcelIgnore;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.persistence.Transient;
import java.text.SimpleDateFormat;

//分页工具类
@Setter
@Getter
@ToString
public class Page {

    @ExcelIgnore
    private SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");//日期工具类

    /**
     * 当前页
     */
    @Transient
    @ExcelIgnore
    private Integer page;
    /**
     * 每页限制数
     */
    @Transient
    @ExcelIgnore
    private Integer limit;

    @Transient
    @ExcelIgnore
    private Integer beginIndex;//开始页

    public Integer getPage() {
        return page;
    }

    public void setPage(Integer page) {
        this.page = page;
        this.beginIndex = Integer.valueOf((page.intValue() - 1) * (limit == null ? 9999:limit.intValue()));
    }
}
